package com.gzhryc.shared_device.oem.code.member.dao;

import com.gzhryc.jdbc.Conditions;
import com.gzhryc.jdbc.DateBranchTableDao;
import com.gzhryc.jdbc.Query;
import com.gzhryc.shared_device.oem.code.member.dao.db.MemberTransferMoneyOrder;

import java.sql.SQLException;
import java.util.Date;

public class MemberTransferMoneyOrderDao extends DateBranchTableDao<MemberTransferMoneyOrder> {

    public MemberTransferMoneyOrderDao(String jdbcKey) {
        super(jdbcKey, new Date(), 1);
    }

    public MemberTransferMoneyOrderDao(String jdbcKey, Date date) {
        super(jdbcKey, date);
    }
    
    public Long sumTransferMoneyByCondition(Conditions conditions) throws SQLException {
        String sql = "SELECT SUM(money) FROM " + this.tableName;
        Query query = new Query(sql);
        query.appendSql(conditions.toSql(query.getParams(),true));
        return this.jdbcHelper.getFirstField(query,Long.class);
    }
}
